import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'dva'
import { Row,Col,Card,Tabs } from 'antd'
import { routerRedux } from 'dva/router'
import List from './List'
import Modal from './modal'
import Search from './searchBottom'

const FileTransfer = ({location,dispatch,fileTransfer,loading}) => {
	const { list,visible,infoData,department2,depUser,pagination1,params } = fileTransfer
	const modalProps = {
		visible,
		infoData,
		department2,
		depUser,
		onOk(){
			dispatch({
				type:'fileTransfer/onModalOk',
				payload:{}
			})
		},
		onCancels(){
			dispatch({
				type:'fileTransfer/onCancels',
				payload:{}
			})
		},
		onUsers(value){
			dispatch({
	        		type: 'fileTransfer/users',
	        		payload:{organizationId:value}
	   		})
		},
		onOk(params){
			dispatch({
	        		type: 'fileTransfer/update',
	        		payload:{
	        			...params
	        		}
	   		})
		}
	}
	const listProps = {	
		list,
		pagination1,
		showModals(){
			dispatch({
				type:'fileTransfer/showModal',
				payload:{}
			})
		},
		showDet(params){
			dispatch({
				type:'fileTransfer/showDet',
				payload:{
					...params
				}
			})
		},
		showDep(params){
			dispatch({
	        		type: 'fileTransfer/dep',
	        		payload: {
		          ...params
		        }
	   		})
		},
		onPageChange (page) {
          const { query, pathname } = location
          dispatch({
                type: 'fileTransfer/searchList',
                payload: {
                  ...params,
                  page: page.current,
                	  pageSize: page.pageSize
                }
              })
	       }, 		
	}	
	const searchProps = {
		pagination1,
		onSearch(params){
			dispatch({
				type:'fileTransfer/searchList',
				payload:{
					...params
				}
			})
		}
	}
	return(
      <div className="content-inner" style={{backgroundColor:'transparent',padding:0}}>
    		<Search {...searchProps}/>
      		<List {...listProps}/>
      	{ visible == true ?
      		<Modal {...modalProps}/>:null
      	}
      	
      </div>			
	)
}

export default connect(({fileTransfer,loading}) => ({fileTransfer,loading}))(FileTransfer)
